package com.onstar.cn.api;

import com.onstar.cn.api.framework.ClazzInjectUtils;
import com.onstar.cn.api.framework.annotation.Path;
import com.onstar.cn.api.framework.annotation.RequestMapping;
import com.onstar.cn.framework.network.entity.RequestEntity;
import com.onstar.cn.framework.utils.GsonHelper;
import com.onstar.cn.mag.joinme.RegisterRequestEntity;

/**
* @ClassName: JoinmeService
* @Description: 注册，升级接口
* @author 6335yz
* @date 2015年9月6日 下午2:47:43
 */

///	api/v3/user/register/info3/code/send Info3.0统一发送验证码
//		POST /api/v3/user/register/info3/code/validation Info3.0校验验证码
//		POST /api/v3/user/register/info3/subscriber Info3.0 注册车主0-2
//		POST /api/v3/user/register/info3/update Info3.0 更新用户信息
//		POST /api/v3/user/register/info3/upgrade Info3.0 用户升级
//		POST /api/v3/user/register/info3/visitor
@Path("/msp/api/v3/user")
public class JoinmeInfo3Service {

	private String serverURL;

	public JoinmeInfo3Service(String serverURL) {
		this.serverURL = serverURL;
//		this.serverURL = "http://113.52.176.197:51611";
//		this.serverURL = "https://api-pp1.shanghaionstar.com:20843";
	}
	/**
	 * 注册为车主
	 * @param requestEntity
	 * @return
	 *get /api/v3/legal/documents
	 */
	@RequestMapping("/legal/documents")
	public RequestEntity getLegalDocuments(RequestEntity requestEntity) {
		if (requestEntity == null) {
			requestEntity = new RequestEntity();
		}
		String url = ClazzInjectUtils.injectUrl(getClass(), "getLegalDocuments", requestEntity);
		if(url.contains("/user")){
			url = url.replace("/user","");
		}
		requestEntity.setUrl(serverURL + url);
		return requestEntity;
	}
	/**
	 * 注册为车主
	 * @param requestEntity
	 * @param entity
	 * @return
	 */
	@RequestMapping("/register/info3/subscriber")
	public RequestEntity registerToSubscriber(RequestEntity requestEntity, RegisterRequestEntity entity) {
		if (requestEntity == null) {
			requestEntity = new RequestEntity();
		}
		String url = ClazzInjectUtils.injectUrl(getClass(), "registerToSubscriber", requestEntity, entity);
		requestEntity.setUrl(serverURL + url);
		if(entity!=null) {
			requestEntity.setBody(GsonHelper.toJson(entity));
		}
		return requestEntity;
	}
	/**
	 * 更新用户信息
	 * @param requestEntity
	 * @param entity
	 * @return
	 */
	@RequestMapping("/register/info3/update")
	public RequestEntity updateUserInfo(RequestEntity requestEntity, RegisterRequestEntity entity) {
		if (requestEntity == null) {
			requestEntity = new RequestEntity();
		}
		String url = ClazzInjectUtils.injectUrl(getClass(), "updateUserInfo", requestEntity, entity);
		requestEntity.setUrl(serverURL + url);
		return requestEntity;
	}

	/**
	 * 注册为潜客
	 * @param requestEntity
	 * @param entity
	 * @return
	 */
	@RequestMapping("/register/info3/visitor")
	public RequestEntity registerToVisitor(RequestEntity requestEntity, RegisterRequestEntity entity) {
		if (requestEntity == null) {
			requestEntity = new RequestEntity();
		}
		String url = ClazzInjectUtils.injectUrl(getClass(), "registerToVisitor", requestEntity, entity);
		requestEntity.setUrl(serverURL + url);
		if(entity!=null){
			requestEntity.setBody(GsonHelper.toJson(entity));
		}
		return requestEntity;
	}
	
	/**
	 * 潜客升车主
	 * @param requestEntity
	 * @param entity
	 * @return
	 */
	@RequestMapping("/register/info3/upgrade")
	public RequestEntity registerToUpgrade(RequestEntity requestEntity, RegisterRequestEntity entity) {
		if (requestEntity == null) {
			requestEntity = new RequestEntity();
		}
		String url = ClazzInjectUtils.injectUrl(getClass(), "registerToUpgrade", requestEntity, entity);
		requestEntity.setUrl(serverURL + url);
		if(entity != null){
			requestEntity.setBody(GsonHelper.toJson(entity));
		}
		return requestEntity;
	}
	
	/**
	 * 发送验证码
	 * @param requestEntity
	 * @param entity
	 * @return
	 */
	@RequestMapping("/register/info3/code/send")
	public RequestEntity registerCode(RequestEntity requestEntity, RegisterRequestEntity entity) {
		if (requestEntity == null) {
			requestEntity = new RequestEntity();
		}
		String url = ClazzInjectUtils.injectUrl(getClass(), "registerCode", requestEntity, entity);
		requestEntity.setUrl(serverURL + url);
		if(entity!=null) {
			requestEntity.setBody(GsonHelper.toJson(entity));
		}
		return requestEntity;
	}
	
	/**
	 * Validation input code
	 * @param requestEntity
	 * @param entity
	 * @return
	 */
	@RequestMapping("/register/info3/code/validation")
	public RequestEntity registerValidationCode(RequestEntity requestEntity, RegisterRequestEntity entity) {
		if (requestEntity == null) {
			requestEntity = new RequestEntity();
		}
		String url = ClazzInjectUtils.injectUrl(getClass(), "registerValidationCode", requestEntity, entity);
		requestEntity.setUrl(serverURL + url);
		requestEntity.setBody(GsonHelper.toJson(entity));
		return requestEntity;
	}
	
}
